-
Notifications
You must be signed in to change notification settings - Fork 74
Add benchmark your pallet #1189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging/product-ia
Are you sure you want to change the base?
Conversation
nhussein11
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting read, thank you!
parachains/customize-runtime/pallet-development/benchmark-pallet.md
Outdated
Show resolved
Hide resolved
parachains/customize-runtime/pallet-development/benchmark-pallet.md
Outdated
Show resolved
Hide resolved
parachains/customize-runtime/pallet-development/benchmark-pallet.md
Outdated
Show resolved
Hide resolved
parachains/customize-runtime/pallet-development/benchmark-pallet.md
Outdated
Show resolved
Hide resolved
parachains/customize-runtime/pallet-development/benchmark-pallet.md
Outdated
Show resolved
Hide resolved
parachains/customize-runtime/pallet-development/benchmark-pallet.md
Outdated
Show resolved
Hide resolved
parachains/customize-runtime/pallet-development/benchmark-pallet.md
Outdated
Show resolved
Hide resolved
parachains/customize-runtime/pallet-development/benchmark-pallet.md
Outdated
Show resolved
Hide resolved
parachains/customize-runtime/pallet-development/benchmark-pallet.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request comprehensively rewrites the pallet benchmarking guide, transforming it from a general framework overview into a hands-on tutorial that builds on the pallet development series. The changes provide step-by-step instructions for benchmarking custom pallets, from creating benchmarking modules to integrating generated weights into production runtimes.
Key changes:
- Complete rewrite of the benchmark guide with practical, actionable steps for the custom counter pallet example
- Title updates for consistency: "Pallet Testing" β "Unit Test Pallets" and "Benchmarking FRAME Pallets" β "Benchmark Your Pallet"
- Addition of detailed explanations for each step, including weight trait definitions, runtime integration, and production deployment
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
benchmark-pallet.md |
Complete rewrite from conceptual overview to practical tutorial with code examples for benchmarking custom pallets |
pallet-testing.md |
Title updated to "Unit Test Pallets" for better clarity and consistency |
create-a-pallet.md |
Added reference to setup guide for Polkadot Omni Node and Chain Spec Builder |
.nav.yml |
Updated navigation title to match renamed "Unit Test Pallets" |
llms.txt, llms-full.jsonl, .ai/* |
Regenerated AI-ready documentation files with updated content |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| curl -L https://raw.githubusercontent.com/paritytech/polkadot-sdk/refs/tags/polkadot-stable2412/substrate/.maintain/frame-weight-template.hbs \ | ||
| --output ./pallets/pallet-custom/frame-weight-template.hbs |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The curl command is missing the -L flag to follow redirects in one location but has it in another. For consistency with line 314, this curl command should also include the -L flag to ensure redirects are followed properly.
curl -L https://raw.githubusercontent.com/paritytech/polkadot-sdk/refs/tags/polkadot-stable2412/substrate/.maintain/frame-weight-template.hbs \
--output ./pallets/pallet-custom/frame-weight-template.hbs| #[frame::pallet] | ||
| pub mod pallet { | ||
| use frame::prelude::*; | ||
| pub use weights::WeightInfo; | ||
|
|
||
| pub mod weights { | ||
| use frame::prelude::*; | ||
|
|
||
| pub trait WeightInfo { | ||
| fn set_counter_value() -> Weight; | ||
| fn increment() -> Weight; | ||
| fn decrement() -> Weight; | ||
| } | ||
|
|
||
| impl WeightInfo for () { | ||
| fn set_counter_value() -> Weight { | ||
| Weight::from_parts(10_000, 0) | ||
| } | ||
| fn increment() -> Weight { | ||
| Weight::from_parts(15_000, 0) | ||
| } | ||
| fn decrement() -> Weight { | ||
| Weight::from_parts(15_000, 0) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // ... rest of pallet | ||
| } | ||
| ``` |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title in the code block differs from the actual file path. The file path shown is pallets/pallet-custom/src/benchmarking.rs but the title attributes indicate pallets/pallet-custom/src/lib.rs. This inconsistency could confuse readers about which file they should be editing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brunopgalvao Can you please verify which file name is correct for this code block and I will update if needed? Thanks!
dawnkelly09
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question for Bruno. This can be checked by Erin.
| #[frame::pallet] | ||
| pub mod pallet { | ||
| use frame::prelude::*; | ||
| pub use weights::WeightInfo; | ||
|
|
||
| pub mod weights { | ||
| use frame::prelude::*; | ||
|
|
||
| pub trait WeightInfo { | ||
| fn set_counter_value() -> Weight; | ||
| fn increment() -> Weight; | ||
| fn decrement() -> Weight; | ||
| } | ||
|
|
||
| impl WeightInfo for () { | ||
| fn set_counter_value() -> Weight { | ||
| Weight::from_parts(10_000, 0) | ||
| } | ||
| fn increment() -> Weight { | ||
| Weight::from_parts(15_000, 0) | ||
| } | ||
| fn decrement() -> Weight { | ||
| Weight::from_parts(15_000, 0) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // ... rest of pallet | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brunopgalvao Can you please verify which file name is correct for this code block and I will update if needed? Thanks!
π Description
Resolves #1085
π Review Preference
Choose one:
π€ AI-Ready Docs
If content changed, regenerate AI files:
python3 scripts/generate_llms.pyβ Checklist